<template>
    <Teleport to="body">
        <transition name="el-fade-in">
            <div
                class="search-input-box"
                v-if="dialogStore.isSearchDialogVisible"
            >
                <div class="search-box">
                    <el-icon color="#999" size="18px">
                        <Search />
                    </el-icon>
                    <input
                        v-model="keyword"
                        type="text"
                        placeholder="搜索您喜欢的..."
                    />
                    <div class="search-btn" @click="onSearch">搜索</div>
                </div>

                <el-icon
                    class="icon-close"
                    color="#000"
                    size="20px"
                    @click="onClose"
                >
                    <Close />
                </el-icon>
            </div>
        </transition>
    </Teleport>
</template>
<script setup>
import { useContent } from ".";
import { Search, Close } from "@element-plus/icons-vue";
const dialogStore = useDialogStore();
const route = useRoute();
const { keyword, onSearch, onClose } = useContent();

watch(
    () => route.path,
    () => {
        dialogStore.isSearchDialogVisible = false;
    }
);
</script>
<style lang="scss" scoped>
.search-input-box {
    position: fixed;
    top: 90px;
    left: 50%;
    background: #fff;
    transform: translateX(-50%);
    z-index: 9;
    padding: 30px 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.21);

    .icon-close {
        margin-left: 20px;
        cursor: pointer;
    }
}

.search-box {
    width: 800px;
    height: 50px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #5085fb;

    display: flex;
    align-items: center;
    padding: 0 0 0 15px;

    input {
        width: 100%;
        height: 30px;
        padding: 0 15px;
        border: none;
        font-size: 16px;

        &:focus {
            outline: none;
            border: none;
        }
    }

    .search-btn {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 97px;
        height: 46px;
        background: #5085fb;
        border-radius: 12px;
        margin-right: 1px;
        font-size: 18px;
        color: #ffffff;
        line-height: 30px;
        cursor: pointer;
        user-select: none;
    }
}
</style>
